<template>
    <div class="list1">
        <div class="list1_main">
            <noData v-if="!listArr"></noData>
            <div class="list1Box">
                <group>
                    <radio :options="listArr"
                           v-model="radios"
                           @on-change="changeHandle"></radio>
                </group>
            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
import { Radio, Group } from 'vux'
import myMenu from '@/commonComponents/menu'
export default {
    components: {
        Radio,
        Group,
        myMenu
    },
    data () {
        return {
            radios: '', // 勾选值
            listArr: [], // 单位列表数据
            list: [],
            userInfo: {}
        }
    },
    mounted () {
        this.userInfo = JSON.parse(window.localStorage.getItem('userInfo'))
        this.getDepartList()
    },
    methods: {
        // 勾选时
        changeHandle (val, index) {
            console.log(val, index)
            if (val) {
                window.sessionStorage.setItem('deptname', val)
            }
            for (var k in this.list) {
                if (this.list[k].deptName == val) {
                    window.sessionStorage.setItem('deptid', this.list[k].deptId)
                }
            }
        },
        // 获取单位列表
        getDepartList () {
            var that = this
            var params = {
                allowPaging: true,
                business: 'GetDepartsX',
                data: {
                    deptId: this.userInfo.deptId
                },
                pageIndex: 0,
                pageSize: 10000,
                tokenId: 'D0853C0CE5A6A478F5C613B840394FC3',
                userId: this.userInfo.userId
            }
            this.$axiosAjax.getConfigJson(params)
            .then((res) => {
                // console.log(res)
                if (res.data.code == 0) {
                    that.list = res.data.data
                    for (var k in that.list) {
                        that.listArr = that.list[k].deptName
                    }
                }
            })
        }
    }
}
</script>
<style lang="less" scope>
.list1{
    width: 100%;
    height: 100%;
    background-color: #ebeef2;
    .header{
        width: 100%;
        height: 40px;
        line-height: 40px;
        text-align: center;
        position: relative;
        font-size: 18px;
        background: #2269ff;
        color: #fff;
        .vux-x-icon{
            fill:cornsilk;
            position: absolute;
            left: 0;
            top: 5px;
            width: 30px;
            height: 30px;
        }
    }
    .list1_main{
        height: 603px;
        width: 100%;
        background-color: #ebeef2;
        .list1Box{
            width: 100%;
            height: 603px;
            background-color: #ebeef2;
            .weui-search-bar__cancel-btn{
                display: none;
            }
        }
    }
    .weui-cell:before{
        left: 0;
    }
    .weui-cell__bd p{
        width: 316px;
    }
}
</style>
